//package com.example.demo.API.microsoft;// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
//
//import java.net.URI;
//
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.client.utils.URIBuilder;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.DefaultHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.util.EntityUtils;
//import org.json.JSONArray;
//import org.json.JSONObject;
//
//public class JavaSample {
//    private static final String subscriptionKey = "bbf127585e1841f187f6f176b860df15";
//
//    // NOTE: You must use the same region in your REST call as you used to
//    // obtain your subscription keys. For example, if you obtained your
//    // subscription keys from westus, replace "westcentralus" in the URL
//    // below with "westus".
//    //
//    // Free trial subscription keys are generated in the westcentralus region. If you
//    // use a free trial subscription key, you shouldn't need to change this region.
//    private static final String uriBase =
//            "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect";
//
//    private static final String imageWithFaces =
//            "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/c/c3/RH_Louise_Lillian_Gish.jpg\"}";
//
//    private static final String faceAttributes =
//            "age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise";
//
//    public static void main(String[] args) {
//        HttpClient httpclient = new DefaultHttpClient();
//
//    }
//
//
//
//    public String post(HttpClient httpclient,) {
//        try
//        {
//            URIBuilder builder = new URIBuilder(uriBase);
//
//            // Request parameters. All of them are optional.
//            builder.setParameter("returnFaceId", "true");
//            builder.setParameter("returnFaceLandmarks", "false");
//            builder.setParameter("returnFaceAttributes", faceAttributes);
//
//            // Prepare the URI for the REST API call.
//            URI uri = builder.build();
//            HttpPost request = new HttpPost(uri);
//
//            // Request headers.
//            request.setHeader("Content-Type", "application/json");
//            request.setHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
//
//            // Request body.
//            StringEntity reqEntity = new StringEntity(imageWithFaces);
//            request.setEntity(reqEntity);
//
//            // Execute the REST API call and get the response entity.
//            HttpResponse response = httpclient.execute(request);
//            HttpEntity entity = response.getEntity();
//
//            if (entity != null)
//            {
//                // Format and display the JSON response.
//                System.out.println("REST Response:\n");
//
//                String jsonString = EntityUtils.toString(entity).trim();
//                if (jsonString.charAt(0) == '[') {
//                    JSONArray jsonArray = new JSONArray(jsonString);
//                    System.out.println(jsonArray.toString(2));
//                }
//                else if (jsonString.charAt(0) == '{') {
//                    JSONObject jsonObject = new JSONObject(jsonString);
//                    System.out.println(jsonObject.toString(2));
//                } else {
//                    System.out.println(jsonString);
//                }
//                return jsonString;
//            }
//        }
//        catch (Exception e)
//        {
//            // Display error message.
//            System.out.println(e.getMessage());
//            return null;
//        }
//        return null;
//    }
//}